package com.yuanjiu.webmagic;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.yuanjiu.dao.jiuxian.CategoryDao;
import com.yuanjiu.pojo.jiuxian.JiuxianComment;
import com.yuanjiu.pojo.jiuxian.JiuxianSpecObject;

import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.pipeline.Pipeline;


public class JiuxianOutput implements Pipeline {
	
	@Autowired
	private CategoryDao categoryDao;

	@Override
	public void process(ResultItems resultItems, Task task) {
		JiuxianSpecObject jiuxianSpecObject=resultItems.get("jiuObject");
		List<JiuxianComment> comlist=resultItems.get("comment");
		
		if(jiuxianSpecObject!=null){
			try {
				categoryDao.insertJiuxianItem(jiuxianSpecObject);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
		if(comlist!=null){
			try {
				categoryDao.insertJiuxianComment(comlist);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
	}

}
